TCP/IP services. How does the networking system work?
6.1. Overview
The networking part of the software takes up the majority of the system code. We, at
GS3 Technologies, have done extensive testing to insure that we have provided our
customers with the best software possible.
Originally, the software was part of the Microchip PICDEM.net development board.
Microchip included the networking software with the agreement that the code is only
used on Microchip systems.
We decided to start with the Microchip code and add multitasking capabilities using the
Salvo RTOS. However, it soon became evident that we needed a major re-write in
order to add the features we wanted.
After almost two years in development, we have re-written most of the original code
and have added numerous enhancements and functions.
We think the software, as it exists now, is much easier to work with and it allows
much more flexibility for the systems developer.
We believe that the software is now ready for real world embedded systems.
6.2. Q - Where do I start in understanding the source code?
A - Perhaps the best way to start is to give an example of a network packet as it arrives
in the system and eventually gets processed by the final application code.
For this example, we assume that the network packet is an ICMP(ping).
1. A network client sends an ICMP request to our system.
2. The RTL8019AS gets the Ethernet packet, puts it in its queue and asserts the
INT pin. The RTL register: ISR reflects the interrupt as well.
3. main() calls the ProcNICINT(), in mac.c. main() invokes ProcNICINT() inside the
multitasking loop so the delay in processing network packets is small.
4. ProcNICINT() checks if NICINT_PIN has been asserted. The RTL8019AS ISR
register is read and checked for errors.
If the INT register reflects ISR_PRX, a message is put in the
MSG_GOT_PAK_MAC msg queue.
ISR_PRX is set when a packet has arrived successfully with no errors.
5. Task: TaskMACGetHeader(), in macmulti.c, wakes up as a result of the
MSG_GOT_PAK_MAC message.
The CURRP(CURrent Receive buffer Pointer) register is read from the
RTL8019AS.
If the CURRP != NICReadPtrS(Our current value of CURRP) it means that we
got a proper packet.
The Ethernet header is read in from the RTL8019AS.
If the header is type: ETHER_IP, ETHER_ARP or a broadcast packet, it is put in
the MSG_GOT_PAK_IP message queue.